#!/usr/bin/python3

import paramiko
import time
from datetime import datetime



ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())


ssh_client.connect(hostname="192.168.99.100", username="huawei", password="123456")

cmd = ssh_client.invoke_shell()


shijian = datetime.now()
newfile = "ar2_%s_%s_%s_%s_%s_vrpcfg.zip"%(shijian.year,shijian.month,shijian.day,shijian.hour,shijian.minute)
cmd.send("sys\n")
cmd.send("sftp 192.168.99.100\n")
time.sleep(1)
cmd.send("huawei\n")
time.sleep(1)
#cmd.send("y\n")
#time.sleep(1)
#cmd.send("y\n")
#time.sleep(1)
cmd.send("123456\n")
time.sleep(1)
cmd.send("get vrpcfg.zip %s\n"%newfile)
time.sleep(2)
output = cmd.recv(10000)
print(output.decode("utf-8"))


ssh_client.close()